/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package javalens.gui;

import java.awt.Container;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javalens.astronomy.Event;
import javalens.util.Util;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

/**
 *
 * @author vermaak
 */
public class BinaryLensInputPanel extends JPanel implements ActionListener {
    
    private JLabel aLabel = new JLabel("a");
    private JLabel angLabel = new JLabel("ang");
    private JLabel bLabel = new JLabel("b");
    private JLabel fLabel = new JLabel("f");
    private JLabel m0Label = new JLabel("m0");
    private JLabel qLabel = new JLabel("q");
    private JLabel teLabel = new JLabel("te");
    private JLabel tmLabel = new JLabel("tm");
    private JTextField aField = new JTextField("0.0");
    private JTextField angField = new JTextField("0.0");
    private JTextField bField = new JTextField("1.0");
    private JTextField fField = new JTextField("1.0");
    private JTextField m0Field = new JTextField("18");
    private JTextField qField = new JTextField("0.0");
    private JTextField teField = new JTextField("10");
    private JTextField tmField = new JTextField("0");
    private JButton button = new JButton("Set Event");
    private Event event;

    public BinaryLensInputPanel() {
        super();
        setLayout(new GridLayout(0, 2));
        add(new JLabel("Event Parameters"));
        add(new JLabel(""));
        add(bLabel);
        add(bField);
        add(m0Label);
        add(m0Field);
        add(teLabel);
        add(teField);
        add(tmLabel);
        add(tmField);
        add(fLabel);
        add(fField);
        add(aLabel);
        add(aField);
        add(qLabel);
        add(qField);
        add(angLabel);
        add(angField);
        add(button);

        button.addActionListener(this);
    }

    public void actionPerformed(ActionEvent action) {
        if (action.getSource().equals(button)) {
            // create an event for fetching
            event = new Event(
                    Util.JTextFieldToDouble(bField),
                    Util.JTextFieldToDouble(teField),
                    Util.JTextFieldToDouble(tmField),
                    Util.JTextFieldToDouble(m0Field));
            event.setF(Util.JTextFieldToDouble(fField));
            event.setAng(Util.JTextFieldToDouble(angField));
            event.setA(Util.JTextFieldToDouble(aField));
            event.setQ(Util.JTextFieldToDouble(qField));
        }
    }

    public Event getEvent() {
        return event;
    }
    
}
